import java.util.*;

public class 吃掉N个橘子的最少天数 {
    public static Map<Integer,Integer> map = new HashMap<>();
    public int minDays(int n) {
        if (n <= 1) {
            return n;
        }
        if (map.containsKey(n)) return map.get(n);
        int ans = 0;
        int x = n % 2;
        int y = n % 3;
        ans = Math.min(x + 1 + minDays(n / 2),y + 1 + minDays(n / 3));
        map.put(n,ans);
        return ans;
    }
}
